package com.job.yangshida.homework0709.lizi;

/**
 * @author 杨士达
 * @version 1.0
 * @since 2022-07-10 17:10:24
 */
public class TestPhone2 {
    public static void main(String[] args) {
        //返祖造型
        Cellphone cellphone=new PhotoPhone();
        cellphone.chat();//调用自己的方法
        cellphone.mobil();
        //子类的新行为被限制
       // cellphone.photo;
        //下溯造性
        PhotoPhone photoPhone=(PhotoPhone) cellphone;
        photoPhone.photo();
        //GamePhone gamePhone=(GamePhone)cellphone;
       // gamePhone.game();//ClassCastException
        //用instance判断一下 看变量引用的是不是某类型的对象
        if (cellphone instanceof GamePhone){
            GamePhone gamePhone=(GamePhone)cellphone;
            gamePhone.game();
        }else {
            System.out.println("不能转");
        }
    }

}
